package com.example.algorithm.no0011.solution;

import com.example.algorithm.no0011.Solution;

/**
 * @Description 解答实现-盛最多水的容器
 * @ClassName SumTwoNum
 * @Author Administrator
 * @Date 2020/5/16 12:48
 * @Version 1.0.0
 */
public class SolutionImpl implements Solution {
    @Override
    public int maxArea(int[] height) {

        // 左右两边指针，求中间面积
        int left = 0;
        int right = height.length - 1;
        int res = 0;
        while(left < right){
            // 移动高度较小的指针
            res = height[left] < height[right] ?
                    Math.max(res, (right - left) * height[left++]):
                    Math.max(res, (right - left) * height[right--]);
        }
        return res;
    }
}
